export default {
  state: {
    isCollapse: false,
    currentMenu: {
      path: '/home',
      name: 'home',
      label: '首页',
      plabel: '',
      icon: 's-home'
    },
    menu: [],
    tabList: [
      {
        path: '/home',
        name: 'home',
        label: '首页',
        plabel: '',
        icon: 's-home'
      }
    ]
  },
  mutations: {
    selectMenu (state, val) {
      // console.log(val)
      if (val.name !== 'home') {
        state.currentMenu = val
        const result = state.tabList.findIndex(item => item.name === val.name)
        if (result === -1) {
          state.tabList.push(val)
        }
      } else {
        state.currentMenu = {
          path: '/home',
          name: 'home',
          label: '首页',
          plabel: '',
          icon: 's-home'
        }
      }
      // val.name === 'home'? state.currentMenu = null : state.currentMenu = val
    },
    // 删除tab
    closeTab (state, val) {
      const result = state.tabList.findIndex(item => item.name === val.name)
      state.tabList.splice(result, 1)
    },
    collapseMenu (state) {
      state.isCollapse = !state.isCollapse
    }
  },
  actions: {}
}
